package nowCoder;

import java.util.ArrayList;

/**
 * Created by Ghost on 2015/4/8.
 */
public class Find {
    public boolean Find(ArrayList<ArrayList<Integer>> array,int target) {
        if(array.size()==0)
            return false;
        int[][] arr = new int[array.size()][array.get(0).size()];
        for(int i=0;i<array.size();i++){
            for(int j=0;j<array.get(i).size();j++){
                arr[i][j] = array.get(i).get(j);
            }
        }
        int row = array.size(), column = array.get(0).size();
        int startRow = 0, startColumn = arr[0].length-1;
        int i=startRow, j = startColumn;
        while(i<row && j>=0){
            if(arr[i][j]==target)
                return true;
            if(arr[i][j]<target){
                i++;
            } else {
                j--;
            }
        }
        return false;
    }


}
